package com.zpark.dao.impl;

import com.zpark.dao.IAccountDao;
import com.zpark.pojo.Account;
import lombok.Data;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * 账户持久层接口实现类
 */
public class AccountDaoImpl implements IAccountDao {

    private QueryRunner queryRunner;

    public void setQueryRunner(QueryRunner queryRunner) {
        this.queryRunner = queryRunner;
    }

    @Override
    public List<Account> finAll() throws SQLException {
        String sql = "select id, uid, money from account";
        List<Account> query = queryRunner.query(sql, new BeanListHandler<Account>(Account.class));
        return query;
    }
}
